Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend puppet-lint to legacy_check yaml files #235

Merged
merged 14 commits into from
Feb 20, 2025
Merged

Conversation

alex501212
Copy link

With this PR puppet_lint will now be able to do legacy fact checks in yaml files.
I’ve limited checks to legacy facts for yaml and no auto-fixing.

Here is a test yaml file I tested against:



---
version: 5

defaults:  # Used for any hierarchy level that omits these keys.
  datadir: data         # This path is relative to hiera.yaml's directory.
  data_hash: yaml_data  # Use the built-in YAML backend.

hierarchy:
  - name: "LEGACY FACT PATH"
    paths:
        # Used to distinguish between Debian and Ubuntu
      - "os/%{facts.hostname}.yaml"
      - "/var/www/%{::hostname}.yaml"
      - "%{::bios_vendor}.yaml"
  - name: "osfamily/major release"
    paths:
        # Used to distinguish between Debian and Ubuntu
      - "os/%{facts.os.name}/%{facts.os.release.major}.yaml"
  - name: 'common'
    path: 'common.yaml'

After running puppet-lint on this file puppet-lint will correctly flag any legacy_facts warnings:

test/manifests/init.pp - WARNING: legacy fact 'hostname' on line 9 (check: legacy_facts)
test/files/test.yaml - WARNING: legacy fact 'hostname' on line 12 (check: legacy_facts)
test/files/test.yaml - WARNING: legacy fact 'hostname' on line 13 (check: legacy_facts)
test/files/test.yaml - WARNING: legacy fact 'bios_vendor' on line 14 (check: legacy_facts)

Rspec tests are all passing:

Finished in 2.19 seconds (files took 0.66632 seconds to load)
1082 examples, 0 failures

@alex501212 alex501212 requested review from bastelfreak and a team as code owners February 18, 2025 17:18
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

Attention: Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.25%. Comparing base (91b1886) to head (a65c7bf).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...b/puppet-lint/plugins/legacy_facts/legacy_facts.rb 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #235      +/-   ##
==========================================
+ Coverage   93.19%   93.25%   +0.05%     
==========================================
  Files          55       55              
  Lines        1794     1824      +30     
==========================================
+ Hits         1672     1701      +29     
- Misses        122      123       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@david22swan david22swan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but needs a squish, either as part of the merge or manually beforehand

Copy link

@LukasAud LukasAud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@david22swan david22swan merged commit c35705b into main Feb 20, 2025
10 checks passed
@david22swan david22swan deleted the yaml-legacy-facts branch February 20, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants